package com.ymatou.iapi.marketingmanage.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.ymatou.iapi.marketingmanage.parameter.CreateSellerPromotionBean;
import com.ymatou.iapi.marketingmanage.parameter.PromotionPolicy;
import com.ymatou.iapi.marketingmanage.parameter.PromotionValue;
import com.ymatou.iapi.marketingmanage.service.GetConflictProductsCall;
import com.ymatou.iapi.trading.operate.parameter.enums.PromotionTypeEnum;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JSellerPromotionCallService;
import com.ymttest.database.mongo.NewSellerPromotionInfoWapper;
import com.ymttest.database.mongo.YmtBuyerProductWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 获取冲突促销活动 FreeMaker Template自动生成代码 接口
 * http://wiki.ymatou.cn:8090/pages/viewpage.action?pageId=22130076 db
 * http://wiki.ymatou.cn:8090/pages/viewpage.action?pageId=22129111
 */
@TestSuite
public class Ts_GetConflictProducts {
	private static CreateSellerPromotionBean CreateSellerPromotionBean;
	private static GetConflictProductsCall GetConflictProductsCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取冲突商品列表");
	}

	@Before
	public void caseUp() {
		CreateSellerPromotionBean = new CreateSellerPromotionBean();
		GetConflictProductsCall = new GetConflictProductsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetConflictProductsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * @param sellerid
	 * @return
	 */
	private CreateSellerPromotionBean initCreateSellerPromotionBean(int sellerid, PromotionTypeEnum promotionType) {
		CreateSellerPromotionBean cspb = new CreateSellerPromotionBean();
		cspb.setSellerId(sellerid);
		PromotionPolicy PromotionInfo = new PromotionPolicy();
		PromotionInfo.setCanUseSellerCoupon(false);
		PromotionInfo.setIsLimitProduct(false);
		PromotionInfo.setIsSameProductUse(false);
		PromotionInfo.setIsSpecifyProduct(false);
		PromotionInfo.setProductIds(null);
		PromotionInfo.setPromotionBeginTime(YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING));
		PromotionInfo.setPromotionDesc(sellerid + ":满减描述" + TestDataManager.getRandomUUID().toString());
		PromotionInfo.setPromotionEndTime(YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING));
		PromotionInfo.setPromotionName(sellerid + ":满减活动PN");
		PromotionInfo.setPromotionType(promotionType.getCode());
		List<PromotionValue> PromotionValues = new ArrayList<>();
		PromotionInfo.setPromotionValues(PromotionValues);
		List<String> ProductId = new ArrayList<>();
		PromotionInfo.setProductIds(ProductId);
		cspb.setPromotionInfo(PromotionInfo);
		return cspb;
	}

	private void addPromotionValue(CreateSellerPromotionBean cspb, String rv, String dv) {
		PromotionValue e = new PromotionValue();
		if (cspb.getPromotionInfo().getPromotionType() == 3 || cspb.getPromotionInfo().getPromotionType() == 4) {
			if (rv != null) {
				e.setAmountCondition(new BigDecimal(rv));
			}
			e.setValue(new BigDecimal(dv));
		} else {
			if (rv != null) {
				e.setQtyCondition(Integer.valueOf(rv));
			}
			e.setValue(new BigDecimal(dv));
		}
		cspb.getPromotionInfo().getPromotionValues().add(e);
	}


	/**
	 * 验证单独的一个PromotionValue
	 * 
	 * @param type
	 * @param m
	 * @param pv1
	 */
	private void verifyPromotionValue(int type, Map m, PromotionValue pv1) {
		if (type == 1) {
			Logger.verifyEquals(pv1.getQtyCondition().toString(), m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(pv1.getValue(), new BigDecimal(m.get("dv").toString()), "验证dv");

		}
		// 折扣的时候/10
		else if (type == 2) {
			Logger.verifyEquals(pv1.getQtyCondition().toString(), m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(pv1.getValue().divide(BigDecimal.valueOf(10)), new BigDecimal(m.get("dv").toString()), "验证dv");

		} else if (type == 3) {
			Logger.verifyEquals(pv1.getAmountCondition(), new BigDecimal(m.get("rv").toString()), "验证rv");
			Logger.verifyEquals(pv1.getValue(), new BigDecimal(m.get("dv").toString()), "验证dv");
		} else if (type == 4) {
			Logger.verifyEquals(pv1.getAmountCondition(), new BigDecimal(m.get("rv").toString()), "验证rv");
			Logger.verifyEquals(pv1.getValue().divide(BigDecimal.valueOf(10)), new BigDecimal(m.get("dv").toString()), "验证dv");

		} else if (type == 5) {
			Logger.verifyEquals("2", m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(new BigDecimal(0.5), new BigDecimal(m.get("dv").toString()), "验证dv");

		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_001() {
		Logger.start(true, "获取冲突满件减PromotionType1促销活动成功");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_GetConflictProducts_002() {
		Logger.start(true, "不输入PromotionInfo，失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);

			CreateSellerPromotionBean.setPromotionInfo(null);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("错误的请求参数", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_003() {
		Logger.start(true, "IsSpecifyProduct和IsLimitProduct同时为true，失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("指定商品和排除商品只能选择一种方式", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_GetConflictProducts_004() {
		Logger.start(true, "IsSpecifyProduct为true不输入ProductIds，失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("指定商品不能为空", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_005() {
		Logger.start(true, "PromotionEndTime小于PromotionBeginTime，失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setPromotionBeginTime(YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING));
			CreateSellerPromotionBean.getPromotionInfo().setPromotionEndTime(YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING));
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("促销结束时间必须", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_006() {
		Logger.start(true, "PromotionEndTime在PromotionBeginTime1天内，失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setPromotionBeginTime(YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING));
			CreateSellerPromotionBean.getPromotionInfo().setPromotionEndTime(YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING));
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("促销活动时间最短1天，最长30天", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_007() {
		Logger.start(true, "PromotionEndTime在PromotionBeginTime30天后，失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setPromotionBeginTime(YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING));
			CreateSellerPromotionBean.getPromotionInfo().setPromotionEndTime(YMTDateUtil.getBeforeOrNextDay(32, YMTDateUtil.YMDTHMS_STRING));
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("促销活动时间最短1天，最长30天", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_008() {
		Logger.start(true, "获取冲突满件折PromotionType2促销活动成功");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.DiscountIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
			


		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_009() {
		Logger.start(true, "获取冲突满额减PromotionType3促销活动成功");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfAmountEnough);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}


		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_010() {
		Logger.start(true, "获取冲突满额折PromotionType4促销活动成功");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.DiscountIfAmountEnough);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_011() {
		Logger.start(true, "获取冲突满额折SecondHalf5促销活动成功,PromotionValues固定参数{AmountCondition=0,QtyCondition=2,Value=5m}1条");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.HalfIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_012() {
		Logger.start(true, "重复获取冲突满件减PromotionType1指定商品,IsSpecifyProduct为true,ProductIds同一个重复调用,失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(2);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(2, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(2);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			Integer pmid=JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);			

			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(1,ConflictProducts.size(), "验证冲突项");
				//{"Code":200,"Msg":"操作成功","BCode":0,"Data":{"ConflictProducts":[{"PromotionId":605,"PromotionName":"2:满减活动PN","ProductId":"8F026C60-1361-4CF2-94E4-EA08D83FC44D","ProductName":"","PromotionBeginTime":"2017-06-03T16:20:00","PromotionEndTime":"2017-06-04T16:20:59"}]}}
				//TODO 验证数据
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}




	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_GetConflictProducts_013() {
		Logger.start(true, "IsLimitProduct为true不输入ProductIds，失败cp009");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyIsContains("排除商品不能为空", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_014() {
		Logger.start(true, "获取冲突活动指定商品数量超过MaxAddProductCount(disconf:def100),失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(2);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(2, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(101);
			for (Map map : bpw) {
				String pid = map.get("ProductId").toString();
				CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			}
			
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();

			Logger.verifyIsContains("每场促销指定（排除）商品必须", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("400", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("-1", GetConflictProductsCall.getString("BCode"), "验证BCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_015() {
		Logger.start(true, "全场促销活动后再获取冲突活动(IsSpecifyProduct和IsLimitProduct同时为false),失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			//这里旧站点也没有返回 属于活动的冲突
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_016() {
		Logger.start(true, "获取冲突促销活动指定排除商品后(IsLimitProduct=true),再获取冲突此商品的指定促销活动成功(IsSpecifyProduct为true),然后再获取冲突此商品的指定促销活动失败(重复)");
		try {
			Logger.comment("获取冲突(IsLimitProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(3);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(3, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("获取冲突(IsSpecifyProduct=true)");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("再次获取冲突(IsSpecifyProduct=true)");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			JsonArray array = json.get("ConflictProducts").getAsJsonArray();
			Logger.verifyEquals(1, array.size(), "验证冲突条数");
			Logger.verifyIsContains(pid,json.toString(), "验证ConflictProducts中包含pid");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_017() {
		Logger.start(true, "获取冲突促销活动指定排除商品后(IsLimitProduct=true),再获取冲突促销活动指定排除商品(IsLimitProduct=true)失败(不能获取冲突2个排除)");
		try {
			Logger.comment("获取冲突(IsLimitProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("再次获取冲突(IsLimitProduct=true)");
			
			pid = bpw.get(1).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
			//这里旧站点也没有返回 属于活动的冲突

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_018() {
		Logger.start(true, "获取冲突此商品的指定促销活动成功(IsSpecifyProduct为true)后,获取冲突促销活动指定排除商品后(IsLimitProduct=true)商品包含指定商品,成功");
		try {
			Logger.comment("获取冲突(IsSpecifyProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("获取冲突(IsLimitProduct=true)");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
//			json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
//			Logger.verifyEquals(true, json.get("IsSuccess").getAsBoolean(), "验证IsSuccess");
//			Logger.verifyEquals("无冲突满减促销", json.get("Msg").getAsString(), "验证Data.Msg");
//			PromotionId = json.get("PromotionId").getAsInt();
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_019() {
		Logger.start(true, "获取冲突此商品的指定促销活动成功(IsSpecifyProduct为true)2次后,获取冲突促销活动指定排除商品后(IsLimitProduct=true)商品包含全部指定商品,成功");
		try {
			Logger.comment("获取冲突(IsSpecifyProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("第二次获取冲突(IsSpecifyProduct=true)");
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			 pid = bpw.get(1).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			
			Logger.comment("获取冲突(IsLimitProduct=true),包含上面2个商品");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			for (Map map : bpw) {
				CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(map.get("ProductId").toString());
			}
//			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
//			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(1).get("ProductId").toString());
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_020() {
		Logger.start(true, "获取冲突此商品的指定促销活动成功(IsSpecifyProduct为true)后,获取冲突获取冲突促销活动指定排除商品后(IsLimitProduct=true)商品不完全包含指定商品,失败");
		try {
			Logger.comment("获取冲突(IsSpecifyProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("第二次获取冲突(IsSpecifyProduct=true)");
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			 pid = bpw.get(1).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			
			Logger.comment("获取冲突(IsLimitProduct=true),包含上面2个商品");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
//			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(1).get("ProductId").toString());
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			//这里旧站点也没有返回 属于活动的冲突
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(1,ConflictProducts.size(), "验证冲突项");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_021() {
		Logger.start(true, "满件减PromotionType1指定商品,IsSpecifyProduct为true后再获取冲突获取冲突满额减PromotionType3,ProductIds同一个重复调用,失败");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(2);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(2, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(2);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);


			CreateSellerPromotionBean = initCreateSellerPromotionBean(2, PromotionTypeEnum.ReduceIfAmountEnough);
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			//这里旧站点也没有返回 属于活动的冲突
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_022() {
		Logger.start(true, "获取冲突促销活动指定排除商品后(IsLimitProduct=true),提前结束此活动,在获取冲突指定促销活动成功(IsSpecifyProduct为true)包含不存之前排除中商品,成功");
		try {
			Logger.comment("获取冲突(IsLimitProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_023() {
		Logger.start(true, "获取冲突满件减PromotionType1，规则(IsSpecifyProduct为true,ProductIds不同但是value相同)重复失败cp28");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(2);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(2, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			addPromotionValue(CreateSellerPromotionBean, "20", "2");
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(2);
			String pid = bpw.get(0).get("ProductId").toString();
			String pid2 = bpw.get(1).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid2);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();

			//这里旧站点也没有返回 属于活动的冲突
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_024() {
		Logger.start(true, "获取冲突此商品的指定促销活动成功(IsSpecifyProduct为true)2次后,获取冲突促销活动指定排除商品后(IsLimitProduct=true)商品正好是全部指定商品,成功cp40");
		try {
			Logger.comment("获取冲突(IsSpecifyProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			Logger.comment("第二次获取冲突(IsSpecifyProduct=true)");
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			 pid = bpw.get(1).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);
			
			
			
			Logger.comment("获取冲突(IsLimitProduct=true),正好是上面2个商品");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
			
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
//			for (Map map : bpw) {
//				CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
//			}
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(1).get("ProductId").toString());
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("操作成功", GetConflictProductsCall.getString("Msg"), "验证Msg");
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_025() {
		Logger.start(true, "获取冲突(IsSpecifyProduct=true)但productid重复,自动排重成功");
		try {
			Logger.comment("获取冲突(IsSpecifyProduct=true)");
			JSellerPromotionCallService.CancelOrEndPromotion(108);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
			addPromotionValue(CreateSellerPromotionBean, "1", "2");
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(1).get("ProductId").toString());
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(0,ConflictProducts.size(), "验证冲突项");
			}
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetConflictProducts_026() {
		Logger.start(true, "创建2个活动后检查这2个活动中包含的冲突商品成功");
		try {
			JSellerPromotionCallService.CancelOrEndPromotion(2);
			CreateSellerPromotionBean = initCreateSellerPromotionBean(2, PromotionTypeEnum.ReduceIfCountEnough);
			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(true);
			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(false);
			addPromotionValue(CreateSellerPromotionBean, "10", "2");
			List<Map> bpw = new YmtBuyerProductWapper().getLimit(3);
			String pid = bpw.get(0).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			Integer pmid=JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);			

			
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().clear();
			String pid2 = bpw.get(1).get("ProductId").toString();
			String pid3= bpw.get(2).get("ProductId").toString();
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid2);
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid3);
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);		
			JSellerPromotionCallService.CreateSellerPromotion(CreateSellerPromotionBean);	
			
			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(pid);
			GetConflictProductsCall.setData(CreateSellerPromotionBean);
			GetConflictProductsCall.callService();
			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
			if(!json.get("ConflictProducts").isJsonNull()){
				JsonArray ConflictProducts = json.get("ConflictProducts").getAsJsonArray();
				Logger.verifyEquals(3,ConflictProducts.size(), "验证冲突项");
				//{"Code":200,"Msg":"操作成功","BCode":0,"Data":{"ConflictProducts":[{"PromotionId":605,"PromotionName":"2:满减活动PN","ProductId":"8F026C60-1361-4CF2-94E4-EA08D83FC44D","ProductName":"","PromotionBeginTime":"2017-06-03T16:20:00","PromotionEndTime":"2017-06-04T16:20:59"}]}}
				//TODO 验证数据
			}
			Logger.verifyIsContains(pid,json.toString(), "验证冲突项pid");
			Logger.verifyIsContains(pid2,json.toString(), "验证冲突项pid2");
			Logger.verifyIsContains(pid3,json.toString(), "验证冲突项pid3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	@Test
//	@Category({ P2.class })
//	@TestCase
//	public void Tc_GetConflictProducts_047() {
//		Logger.start(true, "获取冲突(IsLimitProduct=true)但productid重复,失败");
//		try {
//			Logger.comment("获取冲突(IsSpecifyProduct=true)");
//			JSellerPromotionCallService.CancelOrEndPromotion(108);
//			CreateSellerPromotionBean = initCreateSellerPromotionBean(108, PromotionTypeEnum.ReduceIfCountEnough);
//			addPromotionValue(CreateSellerPromotionBean, "1", "2");
//			CreateSellerPromotionBean.getPromotionInfo().setIsSpecifyProduct(false);
//			CreateSellerPromotionBean.getPromotionInfo().setIsLimitProduct(true);
//			List<Map> bpw = new YmtBuyerProductWapper().getLimit(4);
//
//			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
//			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(0).get("ProductId").toString());
//			CreateSellerPromotionBean.getPromotionInfo().getProductIds().add(bpw.get(1).get("ProductId").toString());
//			GetConflictProductsCall.setData(CreateSellerPromotionBean);
//			GetConflictProductsCall.callService();
//			Logger.verifyEquals("200", GetConflictProductsCall.getString("Code"), "验证Code");
//			Logger.verifyEquals("0", GetConflictProductsCall.getString("BCode"), "验证BCode");
//			JsonObject json = GetConflictProductsCall.getJsonObject().getAsJsonObject("Data");
//			Logger.verifyEquals(false, json.get("IsSuccess").getAsBoolean(), "验证IsSuccess");
//			Logger.verifyIsContains("重复", json.get("Msg").getAsString(), "验证Data.Msg");
//
//		} catch (Exception e) {
//			Logger.fail(e);
//		}
//	}
}